00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #define USE_ACOPF
00019
00020 #ifndef _ymatrix_components_h_
00021 #define _ymatrix_components_h_
00022
00023 #include "boost/smart_ptr/shared_ptr.hpp"
00024 #include "gridpack/utilities/complex.hpp"
00025 #include "gridpack/component/base_component.hpp"
00026 #include "gridpack/component/data_collection.hpp"
00027
00028 namespace gridpack {
00029 namespace ymatrix {
00030
00031 enum YMatrixMode{YBus};
00032
00033 class YMBus
00034 : public gridpack::component::BaseBusComponent {
00035 public:
00036
00037
00038
00039 YMBus(void);
00040
00041
00042
00043
00044 ~YMBus(void);
00045
00046
00047
00048
00049
00050
00051
00052
00053 bool matrixDiagSize(int *isize, int *jsize) const;
00054
00055
00056
00057
00058
00059
00060
00061
00062 bool matrixDiagValues(ComplexType *values);
00063
00064
00065
00066
00067
00068 void setYBus(void);
00069
00070
00071
00072
00073
00074
00075 void setYBusDiag(double rval, double ival);
00076
00077
00078
00079
00080
00081 gridpack::ComplexType getYBus(void);
00082
00083
00084
00085
00086
00087
00088
00089
00090 void load(const boost::shared_ptr<gridpack::component::DataCollection> &data);
00091
00092
00093
00094
00095
00096
00097 void setMode(int mode);
00098
00099
00100
00101
00102
00103 bool isIsolated(void) const;
00104
00105
00106
00107
00108
00109 void setIsolated(const bool flag);
00110
00111
00112
00113
00114
00115
00116 void getShuntValues(double *bl, double *gl) const;
00117
00118
00119
00120
00121
00122
00123
00124 void setParam(std::string name, double value, int idx);
00125
00126 private:
00127 double p_shunt_gs;
00128 double p_shunt_bs;
00129 bool p_shunt;
00130 int p_mode;
00131 bool p_isolated;
00132
00133
00134
00135 double p_ybusr, p_ybusi;
00136
00137 private:
00138
00139
00140 friend class boost::serialization::access;
00141
00142 template<class Archive>
00143 void serialize(Archive & ar, const unsigned int version)
00144 {
00145 ar & boost::serialization::base_object<gridpack::component::BaseBusComponent>(*this)
00146 & p_shunt_gs
00147 & p_shunt_bs
00148 & p_shunt
00149 & p_mode
00150 & p_isolated
00151 & p_ybusr & p_ybusi;
00152 }
00153
00154 };
00155
00156 class YMBranch
00157 : public gridpack::component::BaseBranchComponent {
00158 public:
00159
00160
00161
00162 YMBranch(void);
00163
00164
00165
00166
00167 ~YMBranch(void);
00168
00169
00170
00171
00172
00173
00174
00175 bool matrixForwardSize(int *isize, int *jsize) const;
00176 bool matrixReverseSize(int *isize, int *jsize) const;
00177
00178
00179
00180
00181
00182
00183
00184 bool matrixForwardValues(ComplexType *values);
00185 bool matrixReverseValues(ComplexType *values);
00186
00187
00188
00189
00190
00191 void setYBus(void);
00192
00193
00194
00195
00196
00197 gridpack::ComplexType getForwardYBus(void);
00198 gridpack::ComplexType getReverseYBus(void);
00199
00200
00201
00202
00203
00204
00205
00206
00207 void load(const boost::shared_ptr<gridpack::component::DataCollection> &data);
00208
00209
00210
00211
00212
00213 gridpack::ComplexType getAdmittance(void);
00214
00215
00216
00217
00218
00219
00220
00221 gridpack::ComplexType getTransformer(YMBus *bus);
00222
00223
00224
00225
00226
00227
00228 gridpack::ComplexType getShunt(YMBus *bus);
00229
00230
00231
00232
00233
00234
00235
00236 void getLineElements(const std::string tag,
00237 gridpack::ComplexType *Yii, gridpack::ComplexType *Yij);
00238
00239
00240
00241
00242
00243
00244
00245 void getRvrsLineElements(const std::string tag,
00246 gridpack::ComplexType *Yii, gridpack::ComplexType *Yij);
00247
00248
00249
00250
00251
00252 std::vector<bool> getLineStatus();
00253
00254
00255
00256
00257
00258 std::vector<std::string> getLineTags();
00259
00260
00261
00262
00263
00264
00265
00266 bool setLineStatus(std::string tag, bool status);
00267
00268
00269
00270
00271
00272
00273 void setMode(int mode);
00274
00275
00276
00277
00278
00279
00280 double getSusceptance(std::string tag);
00281
00282
00283
00284
00285
00286
00287
00288 void setParam(std::string name, double value, int idx);
00289
00290 #ifdef USE_ACOPF
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303 void getYElements(std::vector<double> &yffr, std::vector<double> &yffi,
00304 std::vector<double> &yttr, std::vector<double> &ytti,
00305 std::vector<double> &yftr, std::vector<double> &yfti,
00306 std::vector<double> &ytfr, std::vector<double> &ytfi,
00307 std::vector<bool> &switched);
00308 #endif
00309
00310 private:
00311 std::vector<double> p_reactance;
00312 std::vector<double> p_resistance;
00313 std::vector<double> p_tap_ratio;
00314 std::vector<double> p_phase_shift;
00315 std::vector<double> p_charging;
00316 std::vector<double> p_shunt_admt_g1;
00317 std::vector<double> p_shunt_admt_b1;
00318 std::vector<double> p_shunt_admt_g2;
00319 std::vector<double> p_shunt_admt_b2;
00320 std::vector<bool> p_xform, p_shunt;
00321 int p_mode;
00322 double p_ybusr_frwd, p_ybusi_frwd;
00323 double p_ybusr_rvrs, p_ybusi_rvrs;
00324 std::vector<bool> p_branch_status;
00325 std::vector<bool> p_switched;
00326 std::vector<std::string> p_tag;
00327 int p_elems;
00328 bool p_isolated;
00329 bool p_active;
00330 #ifdef USE_ACOPF
00331 std::vector<double> p_yffr, p_yffi;
00332 std::vector<double> p_yttr, p_ytti;
00333 std::vector<double> p_yftr, p_yfti;
00334 std::vector<double> p_ytfr, p_ytfi;
00335 #endif
00336
00337 private:
00338
00339
00340 friend class boost::serialization::access;
00341
00342 template<class Archive>
00343 void serialize(Archive & ar, const unsigned int version)
00344 {
00345 ar & boost::serialization::base_object<gridpack::component::BaseBranchComponent>(*this)
00346 #ifdef USE_ACOPF
00347 & p_yffr & p_yffi
00348 & p_yttr & p_ytti
00349 & p_yftr & p_yfti
00350 & p_ytfr & p_ytfi
00351 #endif
00352 & p_reactance
00353 & p_resistance
00354 & p_tap_ratio
00355 & p_phase_shift
00356 & p_charging
00357 & p_shunt_admt_g1
00358 & p_shunt_admt_b1
00359 & p_shunt_admt_g2
00360 & p_shunt_admt_b2
00361 & p_xform & p_shunt
00362 & p_mode
00363 & p_ybusr_frwd & p_ybusi_frwd
00364 & p_ybusr_rvrs & p_ybusi_rvrs
00365 & p_branch_status
00366 & p_switched
00367 & p_tag
00368 & p_elems
00369 & p_isolated
00370 & p_active;
00371 }
00372
00373 };
00374
00375
00376 }
00377 }
00378
00379 BOOST_CLASS_EXPORT_KEY(gridpack::ymatrix::YMBus)
00380 BOOST_CLASS_EXPORT_KEY(gridpack::ymatrix::YMBranch)
00381
00382
00383 #endif